layui.use('upload', function(){
  var $ = layui.jquery
  ,upload = layui.upload;
  
  //多图片上传
  upload.render({
    elem: '#test'
    ,url: 'https://httpbin.org/post' //改成自己的上传接口
    ,multiple: true
    ,before: function(obj){
      //预读本地文件示例，不支持ie8
      obj.preview(function(index, file, result){
        $('#demo').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">')
      });
    }
    ,done: function(res){
      //如果上传失败
      //  if(res.code > 0){
      //   return layer.msg('上传失败');
      // }
      //上传成功
    }
    ,error: function(){

    }
  });

});